package com.itheima.demo;

import java.util.Scanner;

public class HealthCalculator {
    public static void main(String[] args) {
        //目标:完成健康计算器
        //1.先让用户输入自己的个人信息：身高、体重、性别、年龄
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入身高：");
        double height = sc.nextDouble();

        System.out.println("请输入体重：");
        double weight = sc.nextDouble();

        System.out.println("请输入性别：");
        String sex = sc.next();     //如接收“男”

        System.out.println("请输入年龄：");
        int age = sc.nextInt();

        double bmi= getBMI(weight,height);
        System.out.println("您的BMI指数是：" + bmi);

        //判断用户bmi值的情况
        if(bmi < 18.5){
            System.out.println("您是Underweight，请增重");
        }
        else if(bmi >= 18.5 && bmi < 24.9){
            System.out.println("您是Normal，请保持");
        }
        else if(bmi >= 25.0 && bmi < 29.9){
            System.out.println("您是Overweight，请减重");
        }
        else{
            System.out.println("您是Obese，请减肥");
        }
        double bmr = getBMR(height,weight,age,sex);
        System.out.println("您的BMR指数是：" + bmr);

    }

    //2.计算BMI指数(把数据交给一个独立的方法来计算并返回这个结果)
    public static double getBMI(double weight,double height){
        return weight/(height*height);
    }

    //3.计算BMR指数(同上)
    public static double getBMR(double height,double weight,int age,String sex){
        if("男".equals(sex)){
            return 66 + (13.7 * weight) + (5 * height) - (6.8 * age);
        }else{
            return 655 + (9.6 * weight) + (1.8 * height) - (4.7 * age);
        }
    }
}
